import repast4py.space as space
from repast4py.core import Agent
from repast4py.space import DiscretePoint as dpt
from repast4py.space import ContinuousSpace
from repast4py.space import ContinuousPoint as cpt
from repast4py import context as ctx
from repast4py import schedule, logging
from mpi4py import MPI


class User(Agent):
    TYPE = 10

    def __init__(self, pt: dpt, id_user: int, rank: int):
        super().__init__(id=id_user, type=User.TYPE, rank=rank)
        self.location = pt
        self.wish_time = float('inf')
        self.review = True
        self.false_review_time = 0

    def evaluate_rider(self, finish_time: int):
        self.review = False if self.wish_time >= finish_time else True
        self.wish_time = finish_time if finish_time < self.wish_time else self.wish_time
        if not self.review:
            if self.false_review_time > 10:
                self.false_review_time = 0
                return False
            else:
                self.false_review_time += 1
        return True
